﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;



namespace GUI_prototype1
{

    
    public partial class Form1 : Form
    {

        public int counter1 = 0;
        public int counter2 = 0;
        public int counter3 = 0;
        public int counter4 = 0;
        public int counter5 = 0;
        public int counter6 = 0;

        public Form1()
        {
            InitializeComponent();
        }

   
     
        private void saToolStripMenuItem_Click(object sender, EventArgs e)// Save as Feature
        {
            
            SaveFileDialog s = new SaveFileDialog();
            if (s.ShowDialog() == DialogResult.OK)
            {
                StreamWriter writer = new StreamWriter(s.OpenFile());
                writer.Write(Routes.SelectedIndex);
                writer.Write(textBox1.Text);
                writer.Close();
            }
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e) //Open Feature
        {
            int size = -1;
            DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
            if (result == DialogResult.OK) // Test result.
            {
                string file = openFileDialog1.FileName;
                try
                {
                    string text = File.ReadAllText(file);
                    string index = text.Substring(0, 1);
                    Routes.SelectedIndex = Convert.ToInt16(index);
                    size = text.Length;
                    textBox1.Text = text.Substring(1, size - 1);

                }
                catch (IOException)
                {
                }
            }
            Console.WriteLine(size); // <-- Shows file size in debugging mode.
            Console.WriteLine(result); // <-- For debugging use only.

        }
       
        // Needs work
        private void printToolStripMenuItem_Click(object sender, EventArgs e) //Print Function
        {
            {

                PrintDialog printDlg = new PrintDialog();
                PrintDocument printDoc = new PrintDocument();
                printDoc.DocumentName = "Bus Routes";
                printDlg.Document = printDoc;
                printDoc.Equals(textBox1);
                printDlg.AllowSelection = true;
                printDlg.AllowSomePages = true;
                //Call ShowDialog
                if (printDlg.ShowDialog() == DialogResult.OK)

                    printDoc.Print();
            }
        }

       
        private void GoButton_Click(object sender, EventArgs e)
        {
            Routes.Enabled = false;
            comboBox1.Enabled = false;
            //comboBox2.Enabled = false;
            progressBar1.Visible = true;
            button1.Visible = true;
            textBox1.Text = "";
            Routes.Text = "";
            comboBox1.Text = "";
            //comboBox2.Text = "";
            progressBar1.MarqueeAnimationSpeed = 20;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            progressBar1.MarqueeAnimationSpeed = 0;
            progressBar1.Visible = false;
            Routes.Enabled = true;
            comboBox1.Enabled = true;
            //comboBox2.Enabled = true;
            button1.Visible = false;

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            counter1++;
            if (counter1 % 2 == 1)
            {
                toolStripButton2.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton4.Enabled = false;
                toolStripButton5.Enabled = false;
                toolStripButton6.Enabled = false;
            }

            else
            {
                toolStripButton2.Enabled = true;
                toolStripButton3.Enabled = true;
                toolStripButton4.Enabled = true;
                toolStripButton5.Enabled = true;
                toolStripButton6.Enabled = true;
            }


        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            counter2++;
            if (counter2 % 2 == 1)
            {
                toolStripButton1.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton4.Enabled = false;
                toolStripButton5.Enabled = false;
                toolStripButton6.Enabled = false;
            }

            else
            {
                toolStripButton1.Enabled = true;
                toolStripButton3.Enabled = true;
                toolStripButton4.Enabled = true;
                toolStripButton5.Enabled = true;
                toolStripButton6.Enabled = true;
            }


        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            counter3++;
            if (counter3 % 2 == 1)
            {
                toolStripButton2.Enabled = false;
                toolStripButton1.Enabled = false;
                toolStripButton4.Enabled = false;
                toolStripButton5.Enabled = false;
                toolStripButton6.Enabled = false;
            }

            else
            {
                toolStripButton2.Enabled = true;
                toolStripButton1.Enabled = true;
                toolStripButton4.Enabled = true;
                toolStripButton5.Enabled = true;
                toolStripButton6.Enabled = true;
            }


        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            counter4++;
            if (counter4 % 2 == 1)
            {
                toolStripButton2.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton1.Enabled = false;
                toolStripButton5.Enabled = false;
                toolStripButton6.Enabled = false;
            }

            else
            {
                toolStripButton2.Enabled = true;
                toolStripButton3.Enabled = true;
                toolStripButton1.Enabled = true;
                toolStripButton5.Enabled = true;
                toolStripButton6.Enabled = true;
            }


        }

        private void editBusesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 buses = new Form3();
            buses.ShowDialog();
        }

        private void editRoutesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form5 stop = new Form5 ();
            stop.ShowDialog();
        }
       
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            counter5++;
            if (counter5 % 2 == 1)
            {
                toolStripButton2.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton1.Enabled = false;
                toolStripButton4.Enabled = false;
                toolStripButton6.Enabled = false;
            }

            else
            {
                toolStripButton2.Enabled = true;
                toolStripButton3.Enabled = true;
                toolStripButton1.Enabled = true;
                toolStripButton4.Enabled = true;
                toolStripButton6.Enabled = true;
            }
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            counter6++;
            if (counter6 % 2 == 1)
            {
                toolStripButton2.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton1.Enabled = false;
                toolStripButton4.Enabled = false;
                toolStripButton5.Enabled = false;
            }

            else
            {
                toolStripButton2.Enabled = true;
                toolStripButton3.Enabled = true;
                toolStripButton1.Enabled = true;
                toolStripButton4.Enabled = true;
                toolStripButton5.Enabled = true;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form6 map = new Form6();
            map.ShowDialog();
        }
        }
    }

